package me.helllp.book.concurrent.ch05;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;

/**
 * JDK框架的Future演示
 * 
 * @author Administrator
 *
 */
public class JdkFutureDemo {
	public static void main(String[] args) throws InterruptedException, ExecutionException {
		FutureTask<String> future = new FutureTask<String>(new JdkRealData("lxm"));
		
		ExecutorService exec = Executors.newFixedThreadPool(1);
		exec.submit(future);
		
		System.out.println("请求完毕！");
		
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			// TODO: handle exception
		}
		
		System.out.println("数据 = " + future.get());
	}
}
